﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data;

namespace DataAccessor.Exceptions
{
    public class CommandExecuteFailedException : DbException
    {
        private readonly string _commandText;
        public string CommandText
        {
            get { return _commandText; }
        }

        private readonly CommandType _commandType;
        public CommandType CommandType
        {
            get { return _commandType; }
        }

        private readonly string _connectionString;
        public string ConnectionString
        {
            get { return _connectionString; }
        }

        private readonly Dictionary<string, object> _commandParamDict;
        public Dictionary<string, object> CommandParamDict
        {
            get { return _commandParamDict; }
        }

        public CommandExecuteFailedException(string commandText,
            CommandType commandType,
            string connectionString,
            Dictionary<string, object> commandParamDict,
            Exception innerException)
            : base(commandText, innerException)
        {
            _commandText = commandText;
            _commandType = commandType;
            _connectionString = connectionString;
            _commandParamDict = commandParamDict;
        }

        public CommandExecuteFailedException(
            string commandText,
            string connectionString,
            Dictionary<string, object> commandParamDict,
            Exception innerException)
            : this(commandText, CommandType.Text, connectionString, commandParamDict, innerException)
        {

        }

        public CommandExecuteFailedException(
            string commandText,
            Dictionary<string, object> commandParamDict,
            Exception innerException)
            : this(commandText, CommandType.Text, string.Empty, commandParamDict, innerException)
        {
        }

        public CommandExecuteFailedException(string commandText, Exception innerException)
            : this(commandText, CommandType.Text, string.Empty, null, innerException)
        {
        }

        public CommandExecuteFailedException(string commandText)
            : this(commandText, CommandType.Text, string.Empty, null, null)
        {
        }
    }
}
